package com.mlnx.data.service.iml;

import com.mlnx.common.form.PageForm;
import com.mlnx.common.utils.MyLog;
import com.mlnx.data.dao.SugarStore;
import com.mlnx.data.entity.SugarInfo;
import com.mlnx.data.pojo.form.SugarInfoForm;
import com.mlnx.data.pojo.vo.SugarInfoVo;
import com.mlnx.data.service.SugarDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zzb
 * @create 2019/10/23 14:25
 */
@Service
public class SugarDataServiceImpl implements SugarDataService {

    private MyLog log = MyLog.getLog(getClass());
    @Autowired
    private SugarStore sugarStore;


    @Override
    public void save(SugarInfo sugarInfo) {
        try {
            sugarStore.save(sugarInfo);
        } catch (Exception e) {
            log.error("收到重复数据");
        }

    }

    @Override
    public void saveList(List<SugarInfo> list) {

    }

    @Override
    public void updateSugar(SugarInfo sugarInfo) {
        sugarStore.updateSugar(sugarInfo);
    }

    @Override
    public void deleteSugars(List<SugarInfo> sugarInfos) {
        for (SugarInfo sugarInfo:sugarInfos
             ) {
            sugarStore.deleteSugar(sugarInfo);
        }
    }

    @Override
    public SugarInfoVo getAllSugars(PageForm pageForm, SugarInfoForm sugarInfoForm) {

        return sugarStore.getPageSugars(pageForm,sugarInfoForm);
    }

    @Override
    public List<SugarInfo> getSugars(Integer patientId, Long startTime, Long endTime) {

        return  sugarStore.getSugars(patientId,startTime,endTime);

    }


}
